<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
</head>

<body>
    <div class="container mt-5">
        <div class="row justify-content-center">
            <div class="col-md-6">
                <div class="card">
                    <div class="card-header">
                        <h3 class="text-center">用户注册</h3>
                    </div>
                    <div class="card-body">
                        <form method="post">
                            {% csrf_token %}

                            <!-- 工程师ID -->
                            <div class="mb-3">
                                <label for="{{ form.username.id_for_label }}" class="form-label">工程师ID:</label>
                                {{ form.username }}
                                {% if form.username.errors %}
                                <div class="text-danger">{{ form.username.errors }}</div>
                                {% endif %}
                            </div>

                            <!-- 邮箱 -->
                            <div class="mb-3">
                                <label for="{{ form.email.id_for_label }}" class="form-label">邮箱:</label>
                                {{ form.email }}
                                {% if form.email.errors %}
                                <div class="text-danger">{{ form.email.errors }}</div>
                                {% endif %}
                            </div>

                            <!-- 姓名 -->
                            <div class="mb-3">
                                <label for="{{ form.full_name.id_for_label }}" class="form-label">姓名:</label>
                                {{ form.full_name }}
                                {% if form.full_name.errors %}
                                <div class="text-danger">{{ form.full_name.errors }}</div>
                                {% endif %}
                            </div>

                            <!-- 部门 -->
                            <div class="mb-3">
                                <label for="{{ form.department.id_for_label }}" class="form-label">部门:</label>
                                {{ form.department }}
                                {% if form.department.errors %}
                                <div class="text-danger">{{ form.department.errors }}</div>
                                {% endif %}
                            </div>

                            <!-- 密码 -->
                            <div class="mb-3">
                                <label for="{{ form.password.id_for_label }}" class="form-label">密码:</label>
                                {{ form.password }}
                                {% if form.password.errors %}
                                <div class="text-danger">{{ form.password.errors }}</div>
                                {% endif %}
                            </div>

                            <!-- 确认密码 -->
                            <div class="mb-3">
                                <label for="{{ form.confirm_password.id_for_label }}" class="form-label">确认密码:</label>
                                {{ form.confirm_password }}
                                {% if form.confirm_password.errors %}
                                <div class="text-danger">{{ form.confirm_password.errors }}</div>
                                {% endif %}
                            </div>

                            <!-- 隐藏字段错误信息 -->
                            <!-- 删除:{% if form.role.errors %} -->
                            <!-- 删除:    <div class="text-danger">{{ form.role.errors }}</div> -->
                            <!-- 删除:{% endif %} -->
                            <!-- 删除:{% if form.kfv_cert_permission.errors %} -->
                            <!-- 删除:    <div class="text-danger">{{ form.kfv_cert_permission.errors }}</div> -->
                            <!-- 删除:{% endif %} -->
                            <!-- 删除:{% if form.kfc_cert_permission.errors %} -->
                            <!-- 删除:    <div class="text-danger">{{ form.kfc_cert_permission.errors }}</div> -->
                            <!-- 删除:{% endif %} -->
                            <!-- 删除:{% if form.dwy_cert_permission.errors %} -->
                            <!-- 删除:    <div class="text-danger">{{ form.dwy_cert_permission.errors }}</div> -->
                            <!-- 删除:{% endif %} -->
                            <!-- 删除:{% if form.ph_cert_permission.errors %} -->
                            <!-- 删除:    <div class="text-danger">{{ form.ph_cert_permission.errors }}</div> -->
                            <!-- 删除:{% endif %} -->
                            <!-- 删除:{% if form.hma_cert_permission.errors %} -->
                            <!-- 删除:    <div class="text-danger">{{ form.hma_cert_permission.errors }}</div> -->
                            <!-- 删除:{% endif %} -->

                            <div class="d-grid">
                                <button type="submit" class="btn btn-primary">注册</button>
                            </div>
                        </form>

                        {% if form.non_field_errors %}
                        <div class="alert alert-danger mt-3">{{ form.non_field_errors }}</div>
                        {% endif %}

                        

                        <div class="text-center mt-3">
                            <a href="{% url 'login' %}">已有账户？点击登录</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>